home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Compilers⁄Interps / GCC-2.3.3r12 / Build / Building GCC next >
Encoding:
Text File  |  1993-04-15  |  5.5 KB  |  115 lines  |  [TEXT/MPS ]

  1. BUILDING MPW GCC
  2.  
  3. This document covers the basics of building and hacking on MPW GCC.
  4.  
  5. [It is also out-of-date.]
  6.  
  7. BISON
  8.  
  9. You need an up-to-date version of Bison, preferably 1.18 or later.  Bison is
  10. probably available from wherever you got GCC, as well as from many other places.
  11.  
  12. [could include Bison with distribution, obviates need for it]
  13.  
  14. REBUILDING
  15.  
  16. To do a basic recompilation, first set the directory to the gcc distribution folder,
  17. then type ":build:BuildOneStage 1".  This will create a new folder
  18. Stage1-Mac68K, modify the necessary files, and create "first stage"
  19. (compiled by MPW C) cpp, cc1, and driver tools, which can be put wherever you like.  The
  20. process takes 10 years on a IIci.  The results are not quite as good as when
  21. GCC compiles itself, but take a lot less time to produce and are fine for testing
  22. changes.
  23.  
  24. To get the best versions, you have to use GCC to compile itself.  Three complete
  25. compilations will be necessary, so do "BuildGCCStages 3".  On a IIci, it will run for
  26. about two lifetimes.  If you say "BuildGCCStages 4" instead, then it will do one more
  27. self-compilation; the fourth-stage compiler should be *completely* identical to the
  28. third stage.  If not, then something is wrong.  In any case, the third stage cpp and
  29. cc1 (in GCC.MPW.s3) are the ones to use (drop them anywhere on your command path).
  30.  
  31. BuildGCCStages needs lots of extra diskspace, about 7Mb/stage over and above
  32. the 10Mb of the source distribution.  Actually, each stage only really needs
  33. the tools built in the previous stage, not the object or temp files, so they
  34. could be deleted to save space.
  35.  
  36. Another speedup is to use the "insn" target instead of "cc1" if only the machine
  37. description "md" has been changed.  MPW makefiles have to do all the dependency
  38. checking before starting execution, which means that they can't take advantage of
  39. the fact that most of the insn-* files don't change when md is changed.  However,
  40. if you make "insn" and then "cc1", the makefile will only have to recompile the
  41. insn-* files that were actually changed by making "insn".
  42.  
  43. BUILDING GCC FOR 68000 and/or SANE
  44.  
  45. At present, one of GCC's unresolved bugs requires both -mc68020 and -mc68881 to be
  46. turned on when compiling itself.  GCC is too slow to be particularly attractive on
  47. older/slower Macs anyway, so this didn't seem like a real hardship. If you really
  48. really need a 68000+SANE GCC, but don't care about having it be self-compiled, you
  49. could build the first stage without -mc68020 and -mc68881 and use that; it is a little
  50. slower, and some optimizations are missing, but otherwise works fine.
  51.  
  52. TESTING
  53.  
  54. This is an important step.  The folder Tests has a few programs that are small
  55. enough to look at the assembly code, plus a version of dhrystone.  You should also
  56. try using gC to build the programs in the MPW CExamples folder.  Of course, when
  57. GCC successfully self-compiles, it is severely tested.  For test suites, we have
  58. used the "C Torture Test" (available on various Internet servers) and the commercial
  59. Plum-Hall test suite.
  60.  
  61. RETARGETING TO EXISTING MACHINES
  62.  
  63. *Not yet documented*
  64.  
  65. RETARGETING TO NEW MACHINES
  66.  
  67. The first thing to do is to study both the GCC manual where it describes how to
  68. retarget, as well as existing machine descriptions, particularly for those machines
  69. with which you are familiar.  Unfortunately, there is no really crystal-clear
  70. description of retargeting anywhere.
  71.  
  72. The easiest approach is to find an existing machine description that is closest
  73. to the one you're interested, build the compiler so you know it will compile and
  74. run correctly, then gradually mutate the description until you're generating code
  75. for your machine.  Many of the more mysterious macros in tm.h are extremely
  76. difficult to write correctly, and if too many are changed all at once, it becomes
  77. well-nigh impossible to discover the cause of a compiler abort.
  78.  
  79. GCC INTERNALS
  80.  
  81. GCC is unusually well-written and well-documented(not!), especially considering the size
  82. and complexity of its intended task.  Nearly all of the machine-independent code
  83. really is machine-independent, although its effectiveness falls off as one gets
  84. further away from the VAX/68K/88K/Mips spectrum of machines and the Unix/Unix-lookalike
  85. spectrum of operating systems.
  86.  
  87. The modifications that were made to get GCC to work under MPW fall into several
  88. categories, each flagged by a distinct preprocessor symbol.
  89.  
  90. MPW is for those changes required by the MPW environment, independent of the compiler
  91. used (typically #includes and file handling).  Most of these occur in contexts where
  92. you'll also see USG (System V Unix), VMS, and MSDOS conditionals.
  93.  
  94. APPLE_C indicates those changes necessary to support Apple's dialect of C, such as
  95. the pascal keyword and direct function definitions.  However, some changes to the
  96. parser have not been so marked (since it gets run through bison).
  97.  
  98. MPW_C is for places in the GCC code that had to be changed to get the MPW C compiler
  99. to handle them correctly.
  100.  
  101. APPLE_HAX is for generic changes that would be worthwhile for any version of GCC.
  102. Some of these remove GCC's limitations with respect to the MPW environment, such as
  103. the need to import variables for each function, and work in conjunction with
  104. bits of the target machine description.
  105.  
  106. MPW_ASM is suppose to be hacks specific to generating MPW asm code, but this has not
  107. been uniformly applied to the gcc source code yet.
  108.  
  109. TROUBLESHOOTING
  110.  
  111. There are two routines crucial to debugging - debug_dump_tree() is a one-argument
  112. function that takes a tree structure and prints it on stderr, while debug_rtx()
  113. does the same for rtl expressions.  These are especially useful to insert just
  114. in front of a call to abort().
  115.